<?php

namespace Home\Controller;

use Think\Controller;

// use Vendor\httpful-2.phar;
class OrderController extends Controller {
	public function index() {
		
		// layout('Public/layout');
		$order = D ( 'order' );
		
		$list = $order->distinct ( true )->field ( 'mobile' )->select ();
		$count = Count ( $list );
		$page = new \Think\Page ( $count, 40 );
		
		// $strsql = "SELECT name,COUNT(*) as bb,mobile,address,adddetail FROM `ss_order` GROUP BY mobile ORDER BY COUNT(*) DESC";
		
		// $list = $order->group('mobile')->limit($page->firstRow.','.$page->listRows)->select();
		
		$list = $order->field ( 'name,mobile,address,count(*) as bb' )->order ( 'bb desc' )->group ( 'mobile' )->limit ( $page->firstRow . ',' . $page->listRows )->select ();
		
		// $list = $order->query($strsql);
		
		// 设置分页参数
		$page->setConfig ( 'first', '首页' );
		$page->setConfig ( 'prev', '上一页' );
		$page->setConfig ( 'next', '下一页' );
		$page->setConfig ( 'last', '末页' );
		$page->setConfig ( 'theme', ' 共%TOTAL_ROW% %HEADER% 共%TOTAL_PAGE%页
%FIRST%   %UP_PAGE% &nbsp;&nbsp;  %LINK_PAGE% &nbsp;&nbsp;   %DOWN_PAGE%   %END%' );
		$show = $page->show ();
		
		$this->assign ( 'list', $list );
		$this->assign ( 'page', $show );
		$this->display ();
	}
	public function dis($dis) {
		// echo $dis;
		$order = D ( 'order' );
		
		
		$sig="+";
		$pos=stripos($dis,$sig);
		if($pos>0)
		{
			$dis=substr($dis,0,$pos);
		}
		
		$map ['address'] = array (
				'like',
				'%' . $dis . '%' 
		);
		
		$list = $order->where ( $map )->order ( 'id desc' )->select ();
		
		$this->assign ( 'list', $list );
		
		$this->display ();
	}
	public function mobile($mobile) {
		// echo $mobile;
		$order = D ( 'order' );
		$map = array (
				'mobile' => $mobile 
		);
		
		$list = $order->where ( $map )->order ( 'id desc' )->select ();
		
		$this->assign ( 'list', $list );
		
		$this->display ();
		
		
	}
	/**
	 * 获取闪送数据并更新
	 * 默认是刷最近一周的
	 */
	public function update() {
		
	 
	}
	
	
	public function test() {
	

// 		echo "hello ww";
		
		Method::test();
	}
	
	public function daterange() {
	
// 		select SUBSTRING(`ordertime`,1,10) as dd,count(*) from `ss_order` group by dd ORDER BY count(*) DESC
		
	}
	
	
	public function getdata() {
	
		echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />";
		// 获取缓存数据
			$login = new Sslogin ();
			$login->load ();
	
		 
	
	}
	
	public function dealdata() {
	
		echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />";
		 
		// 分析数据
		$deal=new SsDealpage();
		$deal->load();
	
	}

}